var app = getApp()
Page({
    data:{
		root:'',
		siteroot:app.setting.siteroot,
		att_url:app.setting.att_url,
		syscolor:app.setting.syscolor,
		account:app.setting.account,
		back_url:'',
    },
	onPullDownRefresh: function (){
		var the=this;
		setTimeout(function(){
			wx.stopPullDownRefresh()
		},1000);
	},
    onLoad:function(options){
        var the = this
        var logo = options?options.logo:'';
		var title = options?options.title:'';
		logo=logo?logo:the.data.siteroot+'../core/resource/images/nopic.jpg';
		wx.setNavigationBarTitle({'title':'在线客服'});
		app.util.get('core/welcome/getkefuset/',function(res){
			//console.log(res)
			if(res.account){
				logo=logo?res.account.logo:logo;
				title=title?res.account.title:title;
			}
			title=title?title:'小程序客服';
			the.setData({
				'kefuset':res.kefuset,
				logo:logo,
				title:title,
			})
		});
    },
	lianxikefu: function(e) {
		var the=this;
		var data=e.currentTarget.dataset;
		//企业微信
		wx.openCustomerServiceChat({
			  extInfo: {url: data.linkurl},
			  corpId: data.corpid,
			  success(res) {
				  console.log(res)
			  },
			  fail(res) {
				  console.log('fail'); console.log(res)
				  app.util.message(res.errMsg);
			  }
		})
    },
	goback:function(){
		var the = this
		var url = the.data.back_url
		console.log('goback.url');console.log(url);
		if(url){
			url = encodeURIComponent(url);
			wx.navigateTo({'url':'/pages/html/html?url='+url});
		}else{
			wx.navigateTo({'url':'/pages/index/index'});
		}
		
	}
})